<?php include("php/dao/DatabaseDAO.php");
include("php/Security.php");

Security::checkAuthenticated();

$databaseDAO = new DatabaseDAO();
$database = $databaseDAO->getDatabase($_GET["databaseId"]);
?>

<!DOCTYPE html>
<html>
<head>
    <title>Manage User Databases</title>

    <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
    <link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<h1><a href="manage.php">Manage feeds</a> | <a href="add_new_database.php">Manage Databases</a></h1>

<h2>Edit user database:</h2>

<div id="addDatabaseFormContainer">
    <form id="addFeedForm" action="php/SaveDatabase.php" method="post">
        <input id="databaseId" name="databaseId" type="hidden" value="<?php echo $database["Id"];?>">
        <label>URL:</label>
        <input type="text" name="databaseUrl" id="databaseUrl" placeholder="Input database URL" value="<?php
        echo $database["URL"];
        ?>" required/></br>

        <label>Database name:</label>
        <input type="text" name="databaseName" id="databaseName" placeholder="Input database name" value="<?php
        echo $database["DatabaseName"];
        ?>" required/></br>

        <label>User:</label>
        <input type="text" name="user" id="user" placeholder="Input username" value="<?php
        echo $database["User"];
        ?>" required/></br>

        <label>Password:</label>
        <input type="password" name="password" id="password" placeholder="Input password" value="<?php
        echo $database["Password"];
        ?>" required/></br>

        <input id="saveDatabaseButton" type="submit" class="button" value="Save">
    </form>
</div>
</body>
</html>